package course10;

import java.text.DecimalFormat;

public class ShuZu {
    public static void main(String[] args) {
        int[] list = {1, 2, 3, 4, 5};
        System.out.println(list[0]);
        int size = 5;
        double[] mylist = new double[size];
        mylist[0] = 5.4;
        mylist[1] = 2.3;
        mylist[2] = 5.3;
        mylist[3] = 7;
        mylist[4] = 9;
        double total = 0;
        //数组求和
        for (int i = 0; i < mylist.length; i++)
            total += mylist[i];
        System.out.println("tayal的总和为：" + total);
        //保留两位小数
        DecimalFormat d = new DecimalFormat("#.000");
        System.out.println("总和为：" + d.format(total));
        for (int i = 0; i < mylist.length; i++)
            System.out.println(mylist[i]);
        for (double e : mylist)
            System.out.println(e);
        double[][] mylist1 = new double[2][];
        mylist1[0] = new double[2];
        mylist1[1] = new double[2];
        mylist1[0][0] = 1;
        mylist1[0][1] = 2;
        for (int i = 0; i < mylist1[0].length; i++)
            for (int j = 0; j < mylist1[1].length; j++)
                System.out.println(mylist1[i][j]);
        double[] mylist2 = {1, 6, 2, 7, 5};
       choose(mylist2,5);
    }
        public static void choose ( double a[], int n){
            int f=0;
            for (int i = 0; i < n-1; i++) {
                if (a[i] > a[i + 1])
                    f = i;
                else
                    f = i + 1;
            }
            System.out.println(a[f]);
        }
}
